package com.suo.mapper;

import com.suo.pojo.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BookMapper {

    @Select("select * from t_book")
    List<Book> selectAll();

    @Select("select * from t_book where id=#{id}")
    Book selectById(int id);

    @Delete("delete from t_book where id = #{id}")
    void deleteById(int id);

    @ResultMap("BookResultMap")
    @Insert("insert into t_book values (null,#{name},#{price},#{author},#{sales},#{stock},#{imgPath});")
    void add(Book book);

    @Update("update t_book set name = #{name},price = #{price},author = #{author},sales = #{sales},stock = #{stock},img_path = #{imgPath} where id = #{id}")
    void update(Book book);
}
